Level1 = Class.extend({
	init: function(context, images) {
		this.context = context;
		this.image = images;
		this.initEnemyL1 = 4000;
		this.enemyAlive = 0;
	},
	
	initEnemy: function() {
		var self = this;
		
		this.generateRandomEnemies(self);
        this.chooseEnemyInterval = setInterval(function() { 
        	self.generateRandomEnemies(self);
        }, self.initEnemyL1);
	},
	
	generateRandomEnemies: function(self) {
		var self = this;
		
	    var randomNumber = Math.floor(Math.random()*3);
	    this.Shoot = 0;
	    	    	
		switch (randomNumber) {
			case 0:
				self.enemy1 = new Enemy1(self.context, self.image[3]);		
				self.activEnemyPosition = self.enemy1.initEnemy(self.Shoot);
				self.enemy1.shooterEnemy(true);
				self.enemyAlive = 1;
				break;
			case 1:
				self.enemy2 = new Enemy2(self.context, self.image[1]);
				self.activEnemyPosition = self.enemy2.initEnemy(self.Shoot);
				self.enemy2.shooterEnemy(true);
				self.enemyAlive = 2;
				break;
			case 2:
				self.enemy3 = new Enemy3(self.context, self.image[2])
				self.activEnemyPosition = self.enemy3.initEnemy(self.Shoot);
				self.enemy3.shooterEnemy(true);
				self.enemyAlive = 3;
				break;
			default:
				break;
			}
	  
	},
	
	checkedPosition: function(mouseCoordinate) {
		var self = this;
		this.mouseCoordinateX = mouseCoordinate[0];
		this.mouseCoordinateY = mouseCoordinate[1];
       		
        if(this.mouseCoordinateX > self.activEnemyPosition[0] && this.mouseCoordinateX < self.activEnemyPosition[2] &&
        	this.mouseCoordinateY > self.activEnemyPosition[1] && this.mouseCoordinateY < self.activEnemyPosition[3] ){
        
        	this.playerMoney +=100;
            this.playerPoint +=100;
            
            this.Shoot++;
            
            switch (self.enemyAlive) {
			case 1:
				self.enemy1.dyingEnemy(self.Shoot);
                self.enemy1.shooterEnemy(false);
				break;
			case 2:
				self.enemy2.dyingEnemy(self.Shoot);
                self.enemy2.shooterEnemy(false);
				break;
			case 3:
				self.enemy3.dyingEnemy(self.Shoot);
                self.enemy3.shooterEnemy(false);
				break;	
			default:
				break;
			};
			
			if(self.Shoot === 1) {
				setTimeout(function() {
					clearInterval(self.chooseEnemyInterval);   
					self.initEnemy();
				}, 680)
			}
			
          };
  
	}
})